<?php

class Employee extends CI_Controller {
 
       public function __construct()
    {
        parent::__construct();
        //$this->load->model('employee_model');
    }
    
    public  function index(){
        
    //    $data['employee'] = $this->employee_model->get_employee();
        $data['employee'] =get_employee();
        $data['main_content'] = 'admin/employee/list';
        $this->load->view('includes/template', $data);  
 
        }

      public function  get_employee(){
           $c = oci_connect('system', 'Chau1992', 'localhost/oraclechau');
            if (!$c) {
                $m = oci_error();
                trigger_error('Could not connect to database: '. $m['message'], E_USER_ERROR);
            }
           $s = oci_parse($c, "SELECT emp_id,name,birthday,email,emp_level,tax_num,dep_id FROM employee");
           
           if (!$s) {
               $m = oci_error($c);
               trigger_error('Could not parse statement: '. $m['message'], E_USER_ERROR);
          } 
         
           $r = oci_execute($s);
           if (!$r) {
               $m = oci_error($s);
               trigger_error('Could not execute statement: '. $m['message'], E_USER_ERROR);
           }
           echo "<hr />";echo "<hr />";echo "<hr />";
           $emp_list = array();
           while (($row = oci_fetch_array($s, OCI_BOTH))) { 
            $emp_list[] = array($row['EMP_ID'],$row['NAME'],$row['BIRTHDAY'],$row['EMAIL'],$row['EMP_LEVEL'],$row['TAX_NUM'],$row['DEP_ID']);
           
        }
        $data['employee'] =$emp_list;
        $data['main_content'] = 'admin/employee/list';
        $this->load->view('includes/template', $data);  

       
    }
   
}

